/********************************************************************************
 ***                                                                          *** 
 ********************************************************************************
 *                                                                              * 
 *           Prject Name : MEMORIA                                              * 
 *                                                                              * 
 *             File Name : editableCard.h                                       * 
 *                                                                              * 
 *            Programmer : LBW                                                  * 
 *                                                                              * 
 *            Start Date : 2020/12/26                                           * 
 *                                                                              * 
 *           Last Update : 2020/12/26  [LBW]                                    * 
 *                                                                              * 
 *------------------------------------------------------------------------------*
 * Functions:                                                                   * 
 *==============================================================================*/

#ifndef EDITABLECARD_H
#define EDITABLECARD_H

#include <QWidget>

class Nail;
class WordLine;
class QLineEdit;
class QHBoxLayout;
class QVBoxLayout;
class QScrollArea;
class EditableCard : public QWidget
{
	Q_OBJECT
public:
	EditableCard(int cardId,QString heading,QString strSentence,QString strAnser,QString strWordPos,QString strInterference,QWidget *parent = 0);
	void setId(int intId);
	int getId() const;
	QString getHeading() const;
	QString getSentence() const;
	QString getAnswer() const;
	QString getInterference() const;
	QString getWordPos() const;

	void mousePressEvent(QMouseEvent *event) override;
signals:
	void cardPressed(int);
protected:
	void paintEvent(QPaintEvent *);
private slots:
	void returnPressed();
	void nailPressed(int);
	void textChanged(const QString &);
private:
	bool wordCheck();
	void reArray();
	void showNails();	

	int id;
	int wordSum = 0;
	QVector<int> vWordPos,vWordLength;
	QVector<QString> vWord;
	WordLine *wordline;
	QVBoxLayout *mainLayout;
	QScrollArea *wordScrollArea;
	QString wordPos;
	QString strToWrite;
	QString answerRemain;
	
	
	/*
	** 四个用于编辑数据的文本行
	*/
	QLineEdit *heading;
	QLineEdit *sentence;
	QLineEdit *answer;
	QLineEdit *interference;

};

#endif
